package com.trackerapp.app;

import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.preference.PreferenceManager;

import com.trackerapp.database.CellIDCacheManager;
import com.trackerapp.util.MessageUtil;
import com.trackerapp.util.NetworkConnectionUtil;
import com.trackerapp.util.TrackerPreferenceManager;

public class TrackerApplication extends Application{
	private SharedPreferences sharedPreferences;
	private static Context applicationContext;
	
	public void onCreate() {
		super.onCreate();
		
		applicationContext = this.getApplicationContext();
		sharedPreferences = PreferenceManager.getDefaultSharedPreferences(applicationContext);

		MessageUtil.initializeMesageUtil(applicationContext);
		ConnectivityManager connectivityManager = (ConnectivityManager) applicationContext.getSystemService(android.content.Context.CONNECTIVITY_SERVICE);
		NetworkConnectionUtil.initializeNetworkConnectionUtil(connectivityManager);
        CellIDCacheManager.initialiseContext(applicationContext);
        TrackerPreferenceManager.initializePreferenceManager(sharedPreferences);
	}
	
    public void onTerminate() {
        super.onTerminate();
    }
    
    public static Context getContext() {
    	return applicationContext;
    }

}
